home *** CD-ROM | disk | FTP | other *** search
/ New Perspectives on Computer Concepts / New Perspectives on Computer Concepts.iso / np2010c / F1247.ECS < prev    next >
Text File  |  2008-11-19  |  11KB  |  314 lines

  1. |COPYRIGHT 2006 BY MEDIATECHNICS CORPORATION|HEADER|3|Advanced Prolog Queries|0|F1247.FLC|0|0|0|0|0|0|
  2. |***|
  3. |1|1|1|1|0|0|
  4. |OPEN2.MID||0|0|1||0|
  5. ||0|0|0|0|F1247.BMP|5900|6475|4|1|
  6. |1|0|0|0|0|1|1|0|0|0|0|1|1|0|0|0|0|1|1|0|0|0|0|1|0|0|0|0|
  7. |0|0|1|0|0|1|0|0|1|0|0|1|
  8. |***|
  9. |2|1|1|1|0|0|
  10. |||0|0|0||1|
  11. ||10|10|10|10||0|0|0|0|
  12. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  13. |0|0|1|0|0|1|0|0|1|0|0|1|
  14. |***|
  15. |3|1|1|20|0|0|
  16. |F124701.WAV||0|0|1||1|
  17. |Prolog queries can produce information that is not explicitly stored in the knowledge base.|3660|3705|945|2895||0|0|0|0|
  18. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  19. |0|0|1|0|0|1|0|0|1|0|0|1|
  20. |***|
  21. |4|1|1|1|0|0|
  22. |||0|0|0||1|
  23. ||10|10|10|10||0|0|0|0|
  24. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  25. |0|0|1|0|0|1|0|0|1|0|0|1|
  26. |***|
  27. |5|2|1|1|0|0|
  28. |||0|0|0||1|
  29. ||10|10|10|10||0|0|0|0|
  30. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  31. |0|0|1|0|0|1|0|0|1|0|0|1|
  32. |***|
  33. |6|2|1|40|0|0|
  34. |F124702.WAV||0|0|1||1|
  35. |For example, suppose that the knowledge base pizza.txt contains the sizes, shapes, and prices for various pizzas.  You would like to know the size of any round pizzas.|3660|3705|1620|2895||0|0|0|0|
  36. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  37. |0|0|1|0|0|1|0|0|1|0|0|1|
  38. |***|
  39. |7|2|1|1|0|0|
  40. |||0|0|0||1|
  41. ||10|10|10|10||0|0|0|0|
  42. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  43. |0|0|1|0|0|1|0|0|1|0|0|1|
  44. |***|
  45. |8|3|1|1|0|0|
  46. |||0|0|0||1|
  47. ||10|10|10|10||0|0|0|0|
  48. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  49. |0|0|1|0|0|1|0|0|1|0|0|1|
  50. |***|
  51. |9|3|1|45|0|0|
  52. |F124703.WAV||0|0|1||1|
  53. |The knowledge base does not contain a fact such as sizeofroundpizza(14) that would specifically apply to your query.  However, Prolog can find the size of the round pizza using a conjunction of two goals.|1805|4185|1830|2895||0|0|2|0|
  54. |1|3345|2865|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  55. |0|0|1|0|0|1|0|0|1|0|0|1|
  56. |***|
  57. |10|3|1|1|0|0|
  58. |||0|0|0||1|
  59. ||10|10|10|10||0|0|2|0|
  60. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  61. |0|0|1|0|0|1|0|0|1|0|0|1|
  62. |***|
  63. |11|4|1|1|0|0|
  64. |||0|0|0||1|
  65. ||10|10|10|10||0|0|2|0|
  66. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  67. |0|0|1|0|0|1|0|0|1|0|0|1|
  68. |***|
  69. |12|4|1|15|0|0|
  70. |F124704.WAV||0|0|1||1|
  71. |A query such as this one contains two goals.|1050|4900|645|2355||0|0|3|1|
  72. |1|2415|4275|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  73. |0|0|1|0|0|1|0|0|1|0|0|1|
  74. |***|
  75. |13|4|1|20|0|0|
  76. |F124705.WAV||0|0|1||1|
  77. |The first goal directs Prolog to find any pizzas that are round.|2055|4975|675|2895||0|0|3|0|
  78. |1|4560|4290|10|10|1|1|10|10|10|10|1|1|1575|3360|10|10|1|1|10|10|10|10|1|540|3345|420|2790|
  79. |0|0|1|0|0|1|0|0|1|0|0|1|
  80. |***|
  81. |14|4|1|30|0|0|
  82. |F124706.WAV||0|0|1||1|
  83. |The second goal directs Prolog to look for the size of the same pizza that was located by the first goal.  Let's see how it works.|4755|4930|1155|2940||0|0|3|0|
  84. |1|5400|4335|15|15|1|1|10|10|10|10|1|1|4245|3240|10|10|1|1|10|10|10|10|1|3435|3330|420|1995|
  85. |0|0|1|0|0|1|0|0|1|0|0|1|
  86. |***|
  87. |15|4|1|25|0|0|
  88. |F124707.WAV||0|0|1||1|
  89. |To satisfy the first goal, Prolog looks for a fact with "shapeof" as the predicate and "round" as the second argument.|1745|4200|1125|2940||0|0|0|0|
  90. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  91. |0|0|1|0|0|1|0|0|1|0|0|1|
  92. |***|
  93. |16|4|1|1|0|0|
  94. |||0|0|0||1|
  95. ||10|10|10|10||0|0|0|0|
  96. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  97. |0|0|1|0|0|1|0|0|1|0|0|1|
  98. |***|
  99. |17|5|1|1|0|0|
  100. |||0|0|0||1|
  101. ||10|10|10|10||0|0|0|0|
  102. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  103. |0|0|1|0|0|1|0|0|1|0|0|1|
  104. |***|
  105. |18|6|1|1|0|0|
  106. |||0|0|0||1|
  107. ||10|10|10|10||0|0|0|0|
  108. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  109. |0|0|1|0|0|1|0|0|1|0|0|1|
  110. |***|
  111. |19|7|1|1|0|0|
  112. |||0|0|0||1|
  113. ||10|10|10|10||0|0|0|0|
  114. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  115. |0|0|1|0|0|1|0|0|1|0|0|1|
  116. |***|
  117. |20|8|1|1|0|0|
  118. |||0|0|0||1|
  119. ||10|10|10|10||0|0|0|0|
  120. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  121. |0|0|1|0|0|1|0|0|1|0|0|1|
  122. |***|
  123. |21|9|1|1|0|0|
  124. |||0|0|0||1|
  125. ||10|10|10|10||0|0|0|0|
  126. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  127. |0|0|1|0|0|1|0|0|1|0|0|1|
  128. |***|
  129. |22|10|1|1|0|0|
  130. |||0|0|0||1|
  131. ||10|10|10|10||0|0|0|0|
  132. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  133. |0|0|1|0|0|1|0|0|1|0|0|1|
  134. |***|
  135. |23|10|1|25|0|0|
  136. |F124708.WAV||0|0|1||1|
  137. |Prolog finds a fact that satisfies the goal.  It has a "shapeof" predicate and the second argument is "round".|1745|5610|1140|2940||0|0|2|0|
  138. |1|3270|5280|15|15|1|1|10|10|10|10|1|1|735|3270|15|15|1|1|10|10|10|10|1|570|3300|450|2775|
  139. |0|0|1|0|0|1|0|0|1|0|0|1|
  140. |***|
  141. |24|10|1|1|0|0|
  142. |||0|0|0||1|
  143. ||10|10|10|10||0|0|2|0|
  144. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  145. |0|0|1|0|0|1|0|0|1|0|0|1|
  146. |***|
  147. |25|11|1|1|0|0|
  148. |||0|0|0||1|
  149. ||10|10|10|10||0|0|2|0|
  150. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  151. |0|0|1|0|0|1|0|0|1|0|0|1|
  152. |***|
  153. |26|11|1|20|0|0|
  154. |F124709.WAV||0|0|1||1|
  155. |The variable in the goal is Pizza.  That is the first argument, so ...|2250|4825|645|2940||0|0|3|0|
  156. |1|3135|4275|15|15|1|1|10|10|10|10|1|1|1935|3285|15|15|1|1|10|10|10|10|1|1665|3330|420|870|
  157. |0|0|1|0|0|1|0|0|1|0|0|1|
  158. |***|
  159. |27|11|1|15|0|0|
  160. |F124710.WAV||0|0|1||1|
  161. |... Prolog takes the first argument from the fact ...|1760|5580|660|2940||0|0|2|0|
  162. |1|4320|5250|10|10|1|1|10|10|10|10|1|1|7080|5340|15|15|1|1|10|10|10|10|1|7065|5445|345|1155|
  163. |0|0|1|0|0|1|0|0|1|0|0|1|
  164. |***|
  165. |28|11|1|1|0|0|
  166. |||0|0|0||1|
  167. ||10|10|10|10||0|0|2|0|
  168. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  169. |0|0|1|0|0|1|0|0|1|0|0|1|
  170. |***|
  171. |29|12|1|1|0|0|
  172. |||0|0|0||1|
  173. ||10|10|10|10||0|0|2|0|
  174. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  175. |0|0|1|0|0|1|0|0|1|0|0|1|
  176. |***|
  177. |30|12|1|15|0|0|
  178. |F124711.WAV||0|0|1||1|
  179. |... and instantiates it to the variable Pizza.|2615|6945|630|2235||0|0|2|0|
  180. |1|2520|6480|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  181. |0|0|1|0|0|1|0|0|1|0|0|1|
  182. |***|
  183. |31|12|1|1|0|0|
  184. |||0|0|0||1|
  185. ||10|10|10|10||0|0|2|0|
  186. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  187. |0|0|1|0|0|1|0|0|1|0|0|1|
  188. |***|
  189. |32|13|1|1|0|0|
  190. |||0|0|0||1|
  191. ||10|10|10|10||0|0|2|0|
  192. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  193. |0|0|1|0|0|1|0|0|1|0|0|1|
  194. |***|
  195. |33|13|1|20|0|0|
  196. |F124712.WAV||0|0|1||1|
  197. |Next, Prolog tries to satisfy the second goal: sizeof(Pizza, X).|1425|4900|675|2940||0|0|3|1|
  198. |1|4305|4080|10|10|1|1|10|10|10|10|1|1|3735|3225|15|15|1|1|10|10|10|10|1|3450|3315|480|1950|
  199. |0|0|1|0|0|1|0|0|1|0|0|1|
  200. |***|
  201. |34|13|1|30|0|0|
  202. |F124713.WAV||0|0|1||1|
  203. |The variable Pizza is already instantiated to "pizza2".  Therefore, this second goal has become sizeof(pizza2,X).|1455|4810|1215|2940||0|0|0|0|
  204. |1|4170|3975|10|10|1|1|10|10|10|10|1|1|4170|3975|10|10|1|1|10|10|10|10|1|10|10|10|10|
  205. |0|0|1|0|0|1|0|0|1|0|0|1|
  206. |***|
  207. |35|13|1|25|0|0|
  208. |F124714.WAV||0|0|1||1|
  209. |Prolog looks for a fact with "sizeof" as the predicate and "pizza2" as the first argument.|1730|4125|885|2940||0|0|2|0|
  210. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  211. |0|0|1|0|0|1|0|0|1|0|0|1|
  212. |***|
  213. |36|13|1|1|0|0|
  214. |||0|0|0||1|
  215. ||10|10|10|10||0|0|2|0|
  216. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  217. |0|0|1|0|0|1|0|0|1|0|0|1|
  218. |***|
  219. |37|14|1|1|0|0|
  220. |||0|0|0||1|
  221. ||10|10|10|10||0|0|0|0|
  222. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  223. |0|0|1|0|0|1|0|0|1|0|0|1|
  224. |***|
  225. |38|15|1|1|0|0|
  226. |||0|0|0||1|
  227. ||10|10|10|10||0|0|0|0|
  228. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  229. |0|0|1|0|0|1|0|0|1|0|0|1|
  230. |***|
  231. |39|16|1|1|0|0|
  232. |||0|0|0||1|
  233. ||10|10|10|10||0|0|0|0|
  234. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  235. |0|0|1|0|0|1|0|0|1|0|0|1|
  236. |***|
  237. |40|16|1|20|0|0|
  238. |F124715.WAV||0|0|1||1|
  239. |Prolog finds a fact that satisfies the goal "sizeof(pizza2,X)".|1760|4965|630|2940||0|0|2|0|
  240. |1|5415|5685|10|10|1|1|10|10|10|10|1|1|4755|4275|10|10|1|1|10|10|10|10|1|10|10|10|10|
  241. |0|0|1|0|0|1|0|0|1|0|0|1|
  242. |***|
  243. |41|16|1|1|0|0|
  244. |||0|0|0||1|
  245. ||10|10|10|10||0|0|2|0|
  246. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  247. |0|0|1|0|0|1|0|0|1|0|0|1|
  248. |***|
  249. |42|17|1|1|0|0|
  250. |||0|0|0||1|
  251. ||10|10|10|10||0|0|2|0|
  252. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  253. |0|0|1|0|0|1|0|0|1|0|0|1|
  254. |***|
  255. |43|17|1|10|0|0|
  256. |F124716.WAV||0|0|1||1|
  257. |X is the variable.|9415|6300|390|1770||0|0|1|0|
  258. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  259. |0|0|1|0|0|1|0|0|1|0|0|1|
  260. |***|
  261. |44|17|1|1|0|0|
  262. |||0|0|0||1|
  263. ||10|10|10|10||0|0|1|0|
  264. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  265. |0|0|1|0|0|1|0|0|1|0|0|1|
  266. |***|
  267. |45|18|1|1|0|0|
  268. |||0|0|0||1|
  269. ||10|10|10|10||0|0|1|0|
  270. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  271. |0|0|1|0|0|1|0|0|1|0|0|1|
  272. |***|
  273. |46|18|1|20|0|0|
  274. |F124717.WAV||0|0|1||1|
  275. |So Prolog instantiates 14 to the variable X.|9970|6975|855|1770||0|0|1|0|
  276. |1|8490|5295|10|10|1|1|10|10|10|10|1|1|8205|4815|10|10|1|1|10|10|10|10|1|8025|4800|420|600|
  277. |0|0|1|0|0|1|0|0|1|0|0|1|
  278. |***|
  279. |47|18|1|1|0|0|
  280. |||0|0|0||1|
  281. ||10|10|10|10||0|0|1|0|
  282. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  283. |0|0|1|0|0|1|0|0|1|0|0|1|
  284. |***|
  285. |48|19|1|1|0|0|
  286. |||0|0|0||1|
  287. ||10|10|10|10||0|0|1|0|
  288. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  289. |0|0|1|0|0|1|0|0|1|0|0|1|
  290. |***|
  291. |49|19|1|25|0|0|
  292. |F124718.WAV||0|0|1||1|
  293. |Prolog displays the solution using the information instantiated to the variables Pizza and X.|2995|4560|1365|1935||0|0|1|0|
  294. |1|1800|5820|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  295. |0|0|1|0|0|1|0|0|1|0|0|1|
  296. |***|
  297. |50|19|1|25|0|0|
  298. |F124720.WAV||0|0|1||1|
  299. |Prolog satisfied this goal with the information that the size of the round pizza is 14 inches.|2995|4560|1455|1935||0|0|0|0|
  300. |1|10|10|10|10|1|1|10|10|10|10|1|1|705|3360|10|10|1|1|10|10|10|10|1|510|3315|510|4965|
  301. |0|0|1|0|0|1|0|0|1|0|0|1|
  302. |***|
  303. |51|19|1|1|0|0|
  304. |||0|0|0||1|
  305. ||10|10|10|10||0|0|0|0|
  306. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  307. |0|0|1|0|0|1|0|0|1|0|0|1|
  308. |***|
  309. |52|19|1|1|0|0|
  310. |CLOSE2.MID||0|0|1||1|
  311. ||10|10|10|10|ANEND.BMP|4500|6975|4|1|
  312. |1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|1|10|10|10|10|1|10|10|10|10|
  313. |0|0|1|0|0|1|0|0|1|0|0|1|
  314.